package pl.edu.uw.come.mooba.domain;

import java.util.Calendar;

/**
 * //MOODLE_BACKUP/COURSE/USERS/USER
 * @author Piotr Kochański, Tomasz Rybicki
 */
public class User {
    private Long id;
    private String auth;
    private boolean confirmed;
    private boolean deleted;
    private String username;
    private String idnumber;
    private String firstname;
    private String lastname;
    private String email;
    private String institution;
    private String department;
    private Calendar firstaccess;
    private Calendar lastaccess;
    private Calendar lastlogin;

    public static final String ID_TAG = "ID";
    public static final String AUTH_TAG = "AUTH";
    public static final String CONFIRMED_TAG = "CONFIRMED";
    public static final String DELETED_TAG = "DELETED";
    public static final String USERNAME_TAG = "USERNAME";
    public static final String IDNUMBER_TAG = "IDNUMBER";
    public static final String FIRSTNAME_TAG = "FIRSTNAME";
    public static final String LASTNAME_TAG = "LASTNAME";
    public static final String EMAIL_TAG = "EMAIL";
    public static final String INSTITUTION_TAG = "INSTITUTION";
    public static final String DEPARTMENT_TAG = "DEPARTMENT";
    public static final String FIRSTACCESS_TAG = "FIRSTACCESS";
    public static final String LASTACCESS_TAG = "LASTACCESS";
    public static final String LASTLOGIN_TAG = "LASTLOGIN";

    public static final String XPATH = "//MOODLE_BACKUP/COURSE/USERS/USER";   

    public static String getXpath(String role){
    	return "//MOODLE_BACKUP/COURSE/HEADER/ROLES_ASSIGNMENTS/ROLE[SHORTNAME=\""+role+"\"]/ASSIGNMENTS/ASSIGNMENT";
    }


    public User() {
    }

    public User(Long id, String auth, boolean confirmed, boolean deleted, String username, String idnumber, String firstname, String lastname, String email, String institution, String department, Calendar firstaccess, Calendar lastaccess, Calendar lastlogin) {
        this.id = id;
        this.auth = auth;
        this.confirmed = confirmed;
        this.deleted = deleted;
        this.username = username;
        this.idnumber = idnumber;
        this.firstname = firstname;
        this.lastname = lastname;
        this.email = email;
        this.institution = institution;
        this.department = department;
        this.firstaccess = firstaccess;
        this.lastaccess = lastaccess;
        this.lastlogin = lastlogin;
    }


  



    public String getAuth() {
        return auth;
    }

    public void setAuth(String auth) {
        this.auth = auth;
    }

    public boolean isConfirmed() {
        return confirmed;
    }

    public void setConfirmed(boolean confirmed) {
        this.confirmed = confirmed;
    }

    public boolean isDeleted() {
        return deleted;
    }

    public void setDeleted(boolean deleted) {
        this.deleted = deleted;
    }

    public String getDepartment() {
        return department;
    }

    public void setDepartment(String department) {
        this.department = department;
    }

    public String getEmail() {
        return email;
    }

    public void setEmail(String email) {
        this.email = email;
    }

    public Calendar getFirstaccess() {
        return firstaccess;
    }

    public void setFirstaccess(Calendar firstaccess) {
        this.firstaccess = firstaccess;
    }

    public String getFirstname() {
        return firstname;
    }

    public void setFirstname(String firstname) {
        this.firstname = firstname;
    }

    public Long getId() {
        return id;
    }

    public void setId(Long id) {
        this.id = id;
    }

    public String getIdnumber() {
        return idnumber;
    }

    public void setIdnumber(String idnumber) {
        this.idnumber = idnumber;
    }

    public String getInstitution() {
        return institution;
    }

    public void setInstitution(String institution) {
        this.institution = institution;
    }

    public Calendar getLastaccess() {
        return lastaccess;
    }

    public void setLastaccess(Calendar lastaccess) {
        this.lastaccess = lastaccess;
    }

    public Calendar getLastlogin() {
        return lastlogin;
    }

    public void setLastlogin(Calendar lastlogin) {
        this.lastlogin = lastlogin;
    }

    public String getLastname() {
        return lastname;
    }

    public void setLastname(String lastname) {
        this.lastname = lastname;
    }

    public String getUsername() {
        return username;
    }

    public void setUsername(String username) {
        this.username = username;
    }

    @Override
    public String toString() {
        return firstname + " " + lastname + "(" + username + ")" + "[" + email + "]";
    }

    @Override
    public boolean equals(Object obj) {
        if (obj == null) {
            return false;
        }
        if (getClass() != obj.getClass()) {
            return false;
        }
        final User other = (User) obj;
        if (this.id != other.id && (this.id == null || !this.id.equals(other.id))) {
            return false;
        }
        return true;
    }

    @Override
    public int hashCode() {
        int hash = 7;
        hash = 83 * hash + (this.id != null ? this.id.hashCode() : 0);
        return hash;
    }

    


    

}

/*

- <USER>
  <ID>2</ID>
  <AUTH>manual</AUTH>
  <CONFIRMED>1</CONFIRMED>
  <POLICYAGREED>0</POLICYAGREED>
  <DELETED>0</DELETED>
  <USERNAME>admin</USERNAME>
  <PASSWORD>209940bc9bb5f67a985ef03e0e5b3096</PASSWORD>
  <IDNUMBER>$@NULL@$</IDNUMBER>
  <FIRSTNAME>Administracja</FIRSTNAME>
  <LASTNAME>Użytkownik</LASTNAME>
  <EMAIL>root@localhost.pl</EMAIL>
  <EMAILSTOP>0</EMAILSTOP>
  <ICQ />
  <SKYPE />
  <YAHOO />
  <AIM />
  <MSN />
  <PHONE1 />
  <PHONE2 />
  <INSTITUTION />
  <DEPARTMENT />
  <ADDRESS />
  <CITY>Warszawa</CITY>
  <COUNTRY>PL</COUNTRY>
  <LANG>pl_utf8</LANG>
  <THEME />
  <TIMEZONE>99</TIMEZONE>
  <FIRSTACCESS>0</FIRSTACCESS>
  <LASTACCESS>1267965542</LASTACCESS>
  <LASTLOGIN>1267964896</LASTLOGIN>
  <CURRENTLOGIN>1267965541</CURRENTLOGIN>
  <LASTIP>127.0.0.1</LASTIP>
  <SECRET />
  <PICTURE>0</PICTURE>
  <URL />
  <DESCRIPTION />
  <MAILFORMAT>1</MAILFORMAT>
  <MAILDIGEST>0</MAILDIGEST>
  <MAILDISPLAY>1</MAILDISPLAY>
  <HTMLEDITOR>1</HTMLEDITOR>
  <AJAX>1</AJAX>
  <AUTOSUBSCRIBE>1</AUTOSUBSCRIBE>
  <TRACKFORUMS>0</TRACKFORUMS>
  <TIMEMODIFIED>1185370027</TIMEMODIFIED>


 */
